﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MonopolyNOHI2015;

namespace MonopolyTests
{
    [TestClass]
    public class PionTests
    {
        private Spel _spel;
        private Bord _monopolyBord;
        private List<Veld> _velden;
        private Pion _hermanPion;
        private Pion _randyPion;
        private Worp _worp;

        [TestInitialize]
        public void Setup()
        {
            _spel = new Spel();
            _monopolyBord = new Bord();

            _velden = new List<Veld>
            {
                new Veld(0, "Start"),
                new StraatVeld(1, "Dorpsstraat", "Ons Dorp",0,0),
                new Veld(2, "Algemeen fonds"),
                new StraatVeld(3, "Brink", "Ons Dorp",0,0),
                new BelastingVeld(4, "Inkomstenbelasting", 200),
                new StationVeld(5, "Station Zuid"),
                new StraatVeld(6, "Steenstraat", "Arnhem",0,0),
                new Veld(7, "Kans"),
                new StraatVeld(8, "Ketelstraat", "Arnhem",0,0),
                new StraatVeld(9, "Velperplein", "Arnhem",0,0),
                new Veld(10, "Gevangenis"),
                new StraatVeld(11, "Barteljorisstraat", "Haarlem",0,0),
                new NutsVeld(12, "Elektriciteitsbedrijf"),
                new StraatVeld(13, "Zijlweg", "Haarlem",0,0),
                new StraatVeld(14, "Houtstraat", "Haarlem",0,0),
                new StationVeld(15, "Station West"),
                new StraatVeld(16, "Neude", "Utrecht",0,0),
                new Veld(17, "Algemeen fonds"),
                new StraatVeld(18, "Biltstraat", "Utrecht",0,0),
                new StraatVeld(19, "Vreeburg", "Utrecht",0,0),
                new Veld(20, "Vrij parkeren"),
                new StraatVeld(21, "A-Kerkhof", "Groningen",0,0),
                new Veld(22, "Kans"),
                new StraatVeld(23, "Grote Markt", "Groningen",0,0),
                new StraatVeld(24, "Heerestraat", "Groningen",0,0),
                new StationVeld(25, "Station Noord"),
                new StraatVeld(26, "Spui", "'s-Gravenhage",0,0),
                new StraatVeld(27, "Plein", "'s-Gravenhage",0,0),
                new NutsVeld(28, "Waterleiding"),
                new StraatVeld(29, "Lange Poten", "'s-Gravenhage",0,0),
                new Veld(30, "Naar de gevangenis"),
                new StraatVeld(31, "Hofplein", "Rotterdam",0,0),
                new StraatVeld(32, "Blaak", "Rotterdam",0,0),
                new Veld(33, "Algemeen fonds"),
                new StraatVeld(34, "Coolsingel", "Rotterdam",0,0),
                new StationVeld(35, "Station Oost"),
                new Veld(36, "Kans"),
                new StraatVeld(37, "Leidsestraat", "Amsterdam",0,0), 
                new BelastingVeld(38, "Extra belasting", 100),
                new StraatVeld(39, "Kalverstraat", "Amsterdam",0,0)
            };

            _hermanPion = new Pion(_velden[0], false);
            _randyPion = new Pion(_velden[0], true);

            var random = new Random();
            var dobbelstenen = new List<Dobbelsteen>(2)
            {
                new Dobbelsteen(random),
                new Dobbelsteen(random)
            };

            _worp = new Worp(dobbelstenen);
        }

        [TestMethod]
        public void TestOfGetVeldPositie0TerugGeeft()
        {
            Assert.AreEqual(expected: _velden[0].GetVeldPositie(), actual: _hermanPion.GetVeldPositie());
        }

        [TestMethod]
        public void TestOfGetVeldDaarwerkelijkVeld0TerugGeeft()
        {
            _hermanPion.SetVeld(_velden[0]);

            Assert.AreEqual(expected: _velden[0], actual: _hermanPion.GetVeld());
        }

        [TestMethod]
        public void TestOfGetVeldDaarwerkelijkVeld39TerugGeeft()
        {
            _randyPion.SetVeld(_velden[39]);

            Assert.AreEqual(expected: _velden[39], actual: _randyPion.GetVeld());
        }

        [TestMethod]
        public void TestOfPionOpVeld7KomtNaWorpVan7()
        {
            const int aantalGegooideOgen = 7;

            var oudePositiePion = _hermanPion.GetVeldPositie();
            var nieuwePositiePion = _monopolyBord.Velden[aantalGegooideOgen + oudePositiePion];
            _hermanPion.SetVeld(veld: nieuwePositiePion);

            Assert.AreEqual(expected: _monopolyBord.Velden[7], actual: _hermanPion.GetVeld());
        }

        [TestMethod]
        public void TestOfPionInGevangenGezetWordt()
        {
            _randyPion.SetGevangenStatus(true);
            Assert.AreEqual(expected: true, actual: _randyPion.GetGevangenSatus());
        }

        [TestMethod]
        public void TestOfPionUitGevangenGezetWordt()
        {
            _randyPion.SetGevangenStatus(false);
            Assert.AreEqual(expected: false, actual: _randyPion.GetGevangenSatus());
        }
    }
}
